/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.muni.fi.diplomka.servicelayer.dto;

import cz.fi.muni.diplomka.common.Coordinates;
import cz.fi.muni.diplomka.common.enumeration.TileType;
import java.util.Objects;

/**
 * Class representing Tile of game world
 *
 * @author Jakub Kutil
 */
public class Tile implements Comparable<Tile> {

    private Coordinates coordinates;
    private TileType type;

    public Tile() {
    }

    public Tile(Coordinates coordinates, TileType type) {
        this.coordinates = coordinates;
        this.type = type;
    }

    public Coordinates getCoordinates() {
        return coordinates;
    }

    public void setCoordinates(Coordinates coordinates) {
        this.coordinates = coordinates;
    }

    public TileType getType() {
        return type;
    }

    public void setType(TileType type) {
        this.type = type;
    }

    @Override
    public int compareTo(Tile o) {
        if (this.getCoordinates().getY_coordinate() < o.getCoordinates().getY_coordinate()) {
            return 1;
        }
        if (this.getCoordinates().getY_coordinate() > o.getCoordinates().getY_coordinate()) {
            return -1;
        }

        if (this.getCoordinates().getX_coordinate() < o.getCoordinates().getX_coordinate()) {
            return -1;
        }
        if (this.getCoordinates().getX_coordinate() > o.getCoordinates().getX_coordinate()) {
            return 1;
        }
        return 0;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 37 * hash + Objects.hashCode(this.coordinates);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Tile other = (Tile) obj;
        if (!Objects.equals(this.coordinates, other.coordinates)) {
            return false;
        }
        return true;
    }
}
